using AutoMapper;
using Joy.Erp.BasicArchives.Core;

namespace Joy.Erp.BasicArchives.Production
{
    public class PlanOrderAutoMapperProfile : Profile
    {
        public PlanOrderAutoMapperProfile()
        {
            CreateMap<PlanOrder, PlanOrderDto>().MapExtraProperties().ReverseMap();
            CreateMap<PlanOrder, PlanOrderDocumentDto>().MapExtraProperties().ReverseMap();
            CreateMap<PlanOrder, PlanOrderCreateDto>().MapExtraProperties().ReverseMap();
            CreateMap<PlanOrder, PlanOrderUpdateDto>()
                .MapExtraProperties()
                .ForMember(dest => dest.Children, opt => opt.Ignore());
            CreateMap<PlanOrderUpdateDto, PlanOrder>()
                .MapExtraProperties()
                .ForMember(dest => dest.Id, opt => opt.Ignore())
                .ForMember(dest => dest.OrderType, opt => opt.Ignore())
                .ForMember(dest => dest.ItemMaster, opt => opt.Ignore())
                .MapChildren<PlanOrderUpdateDto, PlanOrder, PlanOrderPreparationCreateOrUpdateDto, PlanOrderPreparation>();

            CreateMap<PlanOrderPreparation, PlanOrderPreparationDto>().MapExtraProperties().ReverseMap();
            CreateMap<PlanOrderPreparation, PlanOrderPreparationCreateOrUpdateDto>().MapExtraProperties().ReverseMap();
        }
    }
} 